import Taro, { Component } from '@tarojs/taro'
import { View, Image } from '@tarojs/components'

import PropTypes from 'prop-types'

import classnames from 'classnames'

import { IProps } from '../../pages/home/schemas'

import Content from './Content'

import './index.scss'

export default class XCard extends Component<IProps, {}> {

    render() {

        const { data, onClick } = this.props

        return (
            <View
                className={classnames('card', { 'card-vertical': data.status === 0, 'card-horizontal': data.status === 1 })}
                onClick={onClick}
            >
                {
                    <Image src={data.banner[0].pathName} className='image' mode='widthFix' />
                }
                <View style={{flex: 'auto'}}>
                    <Content data={data} />
                </View>
            </View>
        )
    }

    static propTypes = {
        data: PropTypes.object,
        onClick: PropTypes.func
    }

    static defaultProps = {
        data: {},
        onClick: () => { }
    }
}